package com.offer.CountOnes;

public class Solution {
    /*
     * @param num: An integer
     * @return: An integer
     */
    public int countOnes(int num) {

        if (num == 0) {
            return 0;
        }
        int count = 0;

        while (num > 0) {
            if ((num & 1) > 0) {
                ++count;
            }

            num = num >>> 1;
        }

        return count;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.countOnes(32));
    }


}